#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
long long n,l,r,t,m;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	t=l%n;
	m=r-l;
	if(t+m>=n)cout<<n-1;
	else cout<<t+m;
	return 0;
}
